import 'package:flutter/material.dart';

class HitBlankAreaHideKeyboardWidget extends StatelessWidget {
  final Widget child;
  final VoidCallback? onKeyboardDismiss;

  const HitBlankAreaHideKeyboardWidget({
    Key? key,
    required this.child,
    this.onKeyboardDismiss,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.translucent,
      onTap: () {
        final primaryFocus = FocusManager.instance.primaryFocus;
        if (primaryFocus != null) {
          primaryFocus.unfocus();
          onKeyboardDismiss?.call();
        }
      },
      child: child,
    );
  }
}
